from django.conf.urls.defaults import *
from django.utils.translation import ugettext as _
from polls.feeds import RssFeed, AtomFeed
from polls.models import Poll, Vote
from polls.views import *

feeds = { 
    'rss': RssFeed,
    'atom': AtomFeed,
}

urlpatterns = patterns('',
    # polls
    url(r'^$', PaginatedPollView(Poll, order_by="title"), name="poll_home"),
    url(r'^order_by/(?P<order_by>-?(title|user|pub_date))/$', PaginatedPollView(Poll), name="poll_list"),
    url(r'^create/$', CreatePoll(action="create"), name="poll_create"),
    url(r'^posted/$', PostedView(), name="poll_posted"),
    url(r'^modify/(?P<poll_id>\d+)/$', ModifyPoll(action="modify"), name="poll_modify"),
    url(r'^delete/(?P<poll_id>\d+)/$', DeletePoll(), name="poll_delete"),
    url(r'^view/(?P<poll_id>\d+)/$', ViewPoll(), name="poll_view"),
    # choices
    url(r'^choice/create/(?P<poll_id>\d+)/$', CreateChoice(), name="choice_create"),
    # votes
    url(r'^votes/(?P<order_by>-?(choice|poll|user|pub_date))/$', PaginatedVoteView(Vote, per_page=50), name="vote_list"),
    url(r'^dovote/(?P<poll_id>\d+)/(?P<choice_id>\d+)/$', DoVote(), name="poll_vote"),
    # feeds
    (r'^rss/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds, 'url': 'rss'}),
    (r'^atom/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds, 'url': 'atom'}),
)
